// 换算单位 B
export function formatSize(size: number, k: number = 1024, decimals: number = 1): string {
  if (size === 0) {
    return '0B';
  }
  const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
  const i = Math.floor(Math.log(size) / Math.log(k));

  return parseFloat((size / Math.pow(k, i)).toFixed(decimals)) + units[i];
}
